import { GLabel } from "../../../../../com/mui/controls/GLabel";
import { HTMLUtil } from "../../../../../com/gengine/utils/HTMLUtil";
import { SkillInfo } from "../../../model/SkillInfo";
import { GameDefConfig } from "../../../resource/GameDefConfig";
import { ESkillUseType } from "../../../../../Message/Public/ESkillUseType";
import { SkillRules } from "../../../rules/SkillRules";
import { Language } from "../../../../../extend/language/Language";
//class SkillDetailPanel
    
    export  class SkillDetailPanel /* flash.display.Sprite */
    {
        constructor()
        {
            
            this._skillType = new GLabel();
            this._useType = new GLabel();
            this._distance = new GLabel();
            this._magicNeed = new GLabel();
            this._codeTime = new GLabel();
            this._useDes = new Object /* flash.text.TextField */();
            this._leanedConditon = new GLabel();
            this.detailLabelTxt = [];
            this.initUI();
            mouseEnabled = false;
            mouseChildren = false;
            return;
        }

        /* internal  */initUI(): void
        {
            var loc1=null;
            this._useDes.wordWrap = true;
            this._useDes.multiline = true;
            this._useDes.selectable = false;
            this._useDes.height = 100;
            this._useDes.width = 148;
            this._useDes.textColor = 16580298;
            this._leanedConditon.width = 200;
            var loc2=0;
            while (loc2 < 6) 
            {
                loc1 = new GLabel();
                loc1.x = 0;
                loc1.y = 1 + loc2 * 22;
                loc1.htmlText = HTMLUtil.addColor(this.detailTxt[loc2], "#F5C767");
                addChild(loc1);
                this.detailLabelTxt.push(loc1);
                if (loc2 < 5) 
                {
                    loc1 = this.detailLabel[loc2];
                    loc1.x = 61;
                    loc1.y = 0 + loc2 * 22;
                    addChild(loc1);
                }
                ++loc2;
            }
            this._useDes.x = 61;
            this._useDes.y = 108;
            addChild(this._useDes);
            this._codeTime.width = 120;
            return;
        }

        public updateData(arg1: SkillInfo): void
        {
            this.dispose();
            this._skillInfo = arg1;
            this._skillType.htmlText = HTMLUtil.addColor(GameDefConfig.instance.getSkillType(this._skillInfo.tSkill.skillType).name, "#b1efff");
            this._useType.htmlText = HTMLUtil.addColor(this._skillInfo.getUseType(), "#b1efff");
            if (this._skillInfo.tSkill.useType != ESkillUseType._ESkillUseTypeLearn) 
            {
                this.detailLabelTxt[2].visible = true;
                this.detailLabelTxt[3].visible = true;
                this.detailLabelTxt[4].visible = true;
                this._distance.visible = true;
                this._magicNeed.visible = true;
                this._codeTime.visible = true;
                this._distance.htmlText = HTMLUtil.addColor(this._skillInfo.attackDisStr, "#b1efff");
                this._magicNeed.htmlText = HTMLUtil.addColor(this._skillInfo.magicNeed.toString(), "#09cdff");
                this._codeTime.htmlText = HTMLUtil.addColor(this._skillInfo.cooldownTimeStr, "#6DFF00");
                this._useDes.y = 108;
                this.detailLabelTxt[5].y = 110;
            }
            else 
            {
                this._useDes.y = this._distance.y - 2;
                this.detailLabelTxt[5].y = this._distance.y;
                this.detailLabelTxt[2].visible = false;
                this.detailLabelTxt[3].visible = false;
                this.detailLabelTxt[4].visible = false;
                this._distance.visible = false;
                this._magicNeed.visible = false;
                this._codeTime.visible = false;
            }
            this._useDes.htmlText = HTMLUtil.addColor(this._skillInfo.tSkill.skillDescription, "#b1efff");
            if (SkillRules.isMarrySkill(this._skillInfo.tSkill)) 
            {
                if (!contains(this._leanedConditon)) 
                {
                    this._leanedConditon.htmlText = Language.getString(20373);
                    addChild(this._leanedConditon);
                    this._leanedConditon.x = 0;
                }
                this._leanedConditon.y = this._useDes.y + this._useDes.textHeight + 8;
            }
            else if (contains(this._leanedConditon)) 
            {
                removeChild(this._leanedConditon);
            }
            return;
        }

        public dispose(): void
        {
            this._skillInfo = null;
            return;
        }

        /* internal */ /* const */detailTxt: Array<any>=[Language.getString(20687) + "：", Language.getString(20688) + "：", Language.getString(20689) + "：", Language.getString(20690) + "：", Language.getString(20691) + "：", Language.getString(20692) + "："];

        /* internal */ /* const */detailLabel: Array<any>=[this._skillType, this._useType, this._distance, this._magicNeed, this._codeTime];

        /* internal */ /* var */_skillType: GLabel;

        /* internal */ /* var */_useType: GLabel;

        /* internal */ /* var */_distance: GLabel;

        /* internal */ /* var */_magicNeed: GLabel;

        /* internal */ /* var */_codeTime: GLabel;

        /* internal */ /* var */_useDes: Object /* flash.text.TextField */;

        /* internal */ /* var */_leanedConditon: GLabel;

        /* internal */ /* var */detailLabelTxt: Array<any>;

        /* internal */ /* var */_skillInfo: SkillInfo;
    }
